home *** CD-ROM | disk | FTP | other *** search
- Path: csugrad.cs.vt.edu!not-for-mail
- From: rsuri@csugrad.cs.vt.edu (Raj Suri)
- Newsgroups: comp.lang.c++
- Subject: 2 D arrays in C++ constructors
- Date: 31 Mar 1996 02:37:06 -0500
- Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
- Message-ID: <4jlcn2$kvl@csugrad.cs.vt.edu>
- X-Newsreader: TIN [version 1.2 PL2]
-
- Ok,
- I wrote a c++ class that used an array of integers. However, I didn't know the
- size of the array until the constructor was called. So I did this:
-
- class ... {
-
- private:
- int* ptr;
-
- And then in the constructor, I had this code:
-
- ptr = new int[10];
-
- This works fine. However, now I need to use a two dimensional array in
- which I don't know the dimensions until the constructor is called. I can't
- figure out how to declare ptr and allocate space to it such that I could do the
- following statement:
-
- ptr[2][3] = 4;
-
- Any help.. Thanks in advance.
- -Raj
-
-